import nodemailer from "nodemailer"

const transporter = nodemailer.createTransport({
  host: "smtpdm.aliyun.com",
  port: 465,
  secure: true,
  auth: {
    user: "kenny@smtp.868618.com", // user name
    pass: "YouJian123", // password
  },
})

// export default (title: string, error: unknown) =>
//   transporter.sendMail({
//     from: '"❌❌❌" <kenny@smtp.868618.com>', // sender address
//     to: "shanjiandeshu@163.com", // list of receivers
//     subject: `报错提醒：${title}`, // Subject line
//     html: `<pre>${JSON.stringify(error)}</pre>`, // html body
//   })

type IType = {
  folder: string
  subject: string
  text: string
}

export default ({ folder, subject, text }: IType) =>
  transporter.sendMail({
    from: `"${folder} ❌❌❌" <kenny@smtp.868618.com>`,
    to: "shanjiandeshu@163.com",
    subject,
    text,
  })
